package SwingForms;

import LogicaClasesNew.Categoria;
import LogicaClasesNew.Producto;
import java.util.List;
import javax.swing.JOptionPane;
import LogicaClasesNew.ControladorCategoria;
import LogicaClasesNew.ControladorProducto;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableModel;

public class frmInfoProducto extends javax.swing.JInternalFrame {

    ImageIcon fo0 = null;
    ImageIcon fo1 = null;
    ImageIcon fo2 = null;

    Integer i = -1;

    private DefaultTableModel Productocategoria;

    public frmInfoProducto() {
        initComponents();
        iniciarComboBoxCategoria();
        CrearModeloJT_Productocategoria();

    }

    private void CrearModeloJT_Productocategoria() {
        try {
            Productocategoria = (new DefaultTableModel(
                    null, new String[]{"Categoria"}) {
                        Class[] types = new Class[]{
                            java.lang.String.class
                        };
                        boolean[] canEdit = new boolean[]{
                            false
                        };

                        @Override
                        public Class getColumnClass(int columnIndex) {
                            return types[columnIndex];
                        }

                        @Override
                        public boolean isCellEditable(int rowIndex, int colIndex) {
                            return canEdit[colIndex];
                        }
                    });
            JT_Productocategoria.setModel(Productocategoria);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.toString());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        JL_infoProductoSeleccioneProducto = new javax.swing.JLabel();
        JL_infoProductoInforProducto = new javax.swing.JLabel();
        JB_InfoProductoCerrar = new javax.swing.JButton();
        JL_InfoProductoTitulo = new javax.swing.JLabel();
        JL_InfoProductoPesosUruguayos = new javax.swing.JLabel();
        JTF_InfoProductoTitulo = new javax.swing.JTextField();
        JL_InfoProductoProveedor = new javax.swing.JLabel();
        JL_InfoProductoNumReferencia = new javax.swing.JLabel();
        JTF_InfoProductoProveedor = new javax.swing.JTextField();
        JTF_InfoProductoNumReferencia = new javax.swing.JTextField();
        JL_InfoProductoCategorias = new javax.swing.JLabel();
        JL_InfoProductoDescripcion = new javax.swing.JLabel();
        JTF_InfoProductoDescripcion = new javax.swing.JTextField();
        JL_InfoProductoEspecifiacion = new javax.swing.JLabel();
        JL_InfoProductoPrecio = new javax.swing.JLabel();
        JTF_InfoProductoPrecio = new javax.swing.JTextField();
        JL_infoProductoSeleccioneCategoria = new javax.swing.JLabel();
        JCB_SelecCategorias = new javax.swing.JComboBox();
        JTF_InfoProductoCategorias = new javax.swing.JTextField();
        JCB_SelecProducto = new javax.swing.JComboBox();
        TA_InfoProdEspecificaciones = new java.awt.TextArea();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        JT_Productocategoria = new javax.swing.JTable();
        JL_InfoProductoFoto = new javax.swing.JLabel();
        JB_FotoSiguiente = new javax.swing.JButton();

        setTitle("Informacion Producto");

        JL_infoProductoSeleccioneProducto.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N
        JL_infoProductoSeleccioneProducto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/SeleccioneProductoAzul.png"))); // NOI18N

        JL_infoProductoInforProducto.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N
        JL_infoProductoInforProducto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/infooProducto.png"))); // NOI18N

        JB_InfoProductoCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cerrar.png"))); // NOI18N
        JB_InfoProductoCerrar.setToolTipText("Cierra Ventana");
        JB_InfoProductoCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_InfoProductoCerrarActionPerformed(evt);
            }
        });

        JL_InfoProductoTitulo.setText("Titulo:");

        JL_InfoProductoPesosUruguayos.setForeground(new java.awt.Color(102, 102, 102));
        JL_InfoProductoPesosUruguayos.setText("(Peso Uruguayo)");

        JTF_InfoProductoTitulo.setDisabledTextColor(new java.awt.Color(0, 102, 153));
        JTF_InfoProductoTitulo.setEnabled(false);

        JL_InfoProductoProveedor.setText("Proveedor:");

        JL_InfoProductoNumReferencia.setText("Numero Referencia:");

        JTF_InfoProductoProveedor.setDisabledTextColor(new java.awt.Color(0, 102, 153));
        JTF_InfoProductoProveedor.setEnabled(false);

        JTF_InfoProductoNumReferencia.setDisabledTextColor(new java.awt.Color(0, 102, 153));
        JTF_InfoProductoNumReferencia.setEnabled(false);

        JL_InfoProductoCategorias.setText("Categorias:");

        JL_InfoProductoDescripcion.setText("Descripcion:");

        JTF_InfoProductoDescripcion.setDisabledTextColor(new java.awt.Color(0, 102, 153));
        JTF_InfoProductoDescripcion.setEnabled(false);

        JL_InfoProductoEspecifiacion.setText("Especificaciones:");

        JL_InfoProductoPrecio.setText("Precio:");

        JTF_InfoProductoPrecio.setDisabledTextColor(new java.awt.Color(0, 102, 153));
        JTF_InfoProductoPrecio.setEnabled(false);
        JTF_InfoProductoPrecio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTF_InfoProductoPrecioActionPerformed(evt);
            }
        });

        JL_infoProductoSeleccioneCategoria.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N
        JL_infoProductoSeleccioneCategoria.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/SeleccioneCategoriaAzul.png"))); // NOI18N

        JCB_SelecCategorias.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        JCB_SelecCategorias.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione una Categoria" }));
        JCB_SelecCategorias.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        JCB_SelecCategorias.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JCB_SelecCategoriasMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                JCB_SelecCategoriasMouseEntered(evt);
            }
        });
        JCB_SelecCategorias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JCB_SelecCategoriasActionPerformed(evt);
            }
        });

        JTF_InfoProductoCategorias.setDisabledTextColor(new java.awt.Color(0, 102, 153));
        JTF_InfoProductoCategorias.setEnabled(false);
        JTF_InfoProductoCategorias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTF_InfoProductoCategoriasActionPerformed(evt);
            }
        });

        JCB_SelecProducto.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        JCB_SelecProducto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione Producto" }));
        JCB_SelecProducto.setAction(JCB_SelecCategorias.getAction());
        JCB_SelecProducto.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        JCB_SelecProducto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                JCB_SelecProductoMouseClicked(evt);
            }
        });
        JCB_SelecProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JCB_SelecProductoActionPerformed(evt);
            }
        });

        TA_InfoProdEspecificaciones.setEditable(false);
        TA_InfoProdEspecificaciones.setEnabled(false);
        TA_InfoProdEspecificaciones.setForeground(new java.awt.Color(0, 102, 153));

        jLabel1.setLabelFor(JCB_SelecProducto);
        jLabel1.setText("  NOTA: Seleccionar prod, luego Click Izq para visualizar datos.");
        jLabel1.setToolTipText("");

        JT_Productocategoria.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(JT_Productocategoria);

        JL_InfoProductoFoto.setToolTipText("");
        JL_InfoProductoFoto.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 102, 102), 1, true));

        JB_FotoSiguiente.setText("Siguiente Imágen >>");
        JB_FotoSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_FotoSiguienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(JL_InfoProductoCategorias)
                            .addComponent(JL_InfoProductoProveedor)
                            .addComponent(JL_InfoProductoPrecio)
                            .addComponent(JL_InfoProductoEspecifiacion)
                            .addComponent(JL_InfoProductoDescripcion)
                            .addComponent(JL_InfoProductoNumReferencia)
                            .addComponent(JL_InfoProductoTitulo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(TA_InfoProdEspecificaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(JTF_InfoProductoNumReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(JTF_InfoProductoTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(JTF_InfoProductoDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(JL_InfoProductoFoto, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(JB_FotoSiguiente, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addGap(26, 26, 26))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(JTF_InfoProductoProveedor, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(JTF_InfoProductoPrecio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addComponent(JL_InfoProductoPesosUruguayos)
                                            .addGap(299, 299, 299))
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(JTF_InfoProductoCategorias, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addContainerGap()))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(JB_InfoProductoCerrar)
                                        .addGap(63, 63, 63))))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(JL_infoProductoSeleccioneCategoria)
                                .addGap(18, 18, 18)
                                .addComponent(JCB_SelecCategorias, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(JL_infoProductoSeleccioneProducto)
                                        .addGap(22, 22, 22)
                                        .addComponent(JCB_SelecProducto, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(JL_infoProductoInforProducto)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(6, 6, 6)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(JL_infoProductoSeleccioneCategoria)
                    .addComponent(JCB_SelecCategorias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(JL_infoProductoSeleccioneProducto)
                    .addComponent(JCB_SelecProducto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(JL_infoProductoInforProducto)
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JL_InfoProductoTitulo)
                    .addComponent(JTF_InfoProductoTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JL_InfoProductoNumReferencia)
                    .addComponent(JTF_InfoProductoNumReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JL_InfoProductoDescripcion)
                    .addComponent(JTF_InfoProductoDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(JL_InfoProductoEspecifiacion)
                        .addGap(76, 76, 76))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(TA_InfoProdEspecificaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JL_InfoProductoPrecio)
                    .addComponent(JTF_InfoProductoPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JL_InfoProductoPesosUruguayos))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(JTF_InfoProductoCategorias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(JB_InfoProductoCerrar)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(JL_InfoProductoProveedor)
                                    .addComponent(JTF_InfoProductoProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(JL_InfoProductoCategorias)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(254, 254, 254)
                .addComponent(JL_InfoProductoFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(JB_FotoSiguiente)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void JB_InfoProductoCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_InfoProductoCerrarActionPerformed
        //Oculta formulario
        this.setVisible(false);
    }//GEN-LAST:event_JB_InfoProductoCerrarActionPerformed

    private void JTF_InfoProductoPrecioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTF_InfoProductoPrecioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTF_InfoProductoPrecioActionPerformed

    private void JTF_InfoProductoCategoriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTF_InfoProductoCategoriasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTF_InfoProductoCategoriasActionPerformed


    private void JCB_SelecCategoriasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JCB_SelecCategoriasMouseClicked
        //iniciarComboBoxProducto();
    }//GEN-LAST:event_JCB_SelecCategoriasMouseClicked

    //ELIJE CATOGORIA Y CARBA COMBO PRODUCTOS
    private void JCB_SelecCategoriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JCB_SelecCategoriasActionPerformed
        iniciarComboBoxProducto();
    }//GEN-LAST:event_JCB_SelecCategoriasActionPerformed

    private void JCB_SelecProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JCB_SelecProductoActionPerformed

    }//GEN-LAST:event_JCB_SelecProductoActionPerformed

    private void JCB_SelecProductoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JCB_SelecProductoMouseClicked
       // JCB_InfoProdOrdencompra.setEnabled(false);

        //int prodNum = Integer.parseInt( JCB_SelecProducto.getSelectedItem().toString()); //NOMBRE prod Seleccionado
        String nombreProd = JCB_SelecProducto.getSelectedItem().toString();

        try {
            ControladorProducto jpaprod = new ControladorProducto();
            Producto producto = jpaprod.findProducto2(nombreProd);

            JTF_InfoProductoTitulo.setText(producto.getNombre());
            JTF_InfoProductoNumReferencia.setText(Integer.toString(producto.getNumRef()));
            JTF_InfoProductoDescripcion.setText(producto.getDescripcion());
            JTF_InfoProductoPrecio.setText(Float.toString(producto.getPrecio()));
            JTF_InfoProductoProveedor.setText(producto.getproveedor().getNickname());

            //JTF_InfoProductoCategorias.setText (producto.getCategoria().getNombre());
            TA_InfoProdEspecificaciones.setText(producto.getEspecificacion());
            //Limpio si es que ya contiene algo
            for (int i = 0; i < Productocategoria.getRowCount(); i++) {
                Productocategoria.removeRow(i);
                i -= 1;
            }
            Object A[] = null;
            for (int i = 0; i < producto.getlistacategorias().size(); i++) {
                Productocategoria.addRow(A);
                Productocategoria.setValueAt(producto.getlistacategorias().get(i).getNombre(), i, 0);
            }

            //IMAGEN
            if (producto.getFoto0() != null) { //Si su imagen NO es vacía

                i = 0;

                ImageIcon foto = new ImageIcon(producto.getFoto0());
                Image img = foto.getImage(); //convertimos icon en una imagen
                Image otraimg = img.getScaledInstance(135, 135, java.awt.Image.SCALE_SMOOTH);
                fo0 = new ImageIcon(otraimg);

                JL_InfoProductoFoto.setIcon(fo0);

                if (producto.getFoto1() != null) { //SI cargó una SEGUNDA foto la guardo

                    ImageIcon foto1 = new ImageIcon(producto.getFoto1());
                    Image img1 = foto1.getImage(); //convertimos icon en una imagen
                    Image otraimg1 = img1.getScaledInstance(135, 135, java.awt.Image.SCALE_SMOOTH);

                    fo1 = new ImageIcon(otraimg1);
                    
                    if (producto.getFoto2() != null) {

                        ImageIcon foto2 = new ImageIcon(producto.getFoto2());
                        Image img2 = foto2.getImage(); //convertimos icon en una imagen
                        Image otraimg2 = img2.getScaledInstance(135, 135, java.awt.Image.SCALE_SMOOTH);

                        fo2 = new ImageIcon(otraimg2);
                        
                    }

                }

            }

        } catch (Exception e) {
            getToolkit().beep();
            JOptionPane.showMessageDialog(this, "El error es en carga datos producto\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_JCB_SelecProductoMouseClicked

    private void JCB_SelecCategoriasMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_JCB_SelecCategoriasMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_JCB_SelecCategoriasMouseEntered

    //SIGUIENTE Imagen
    private void JB_FotoSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_FotoSiguienteActionPerformed

        if (i == 0) { //1 imagen
            System.out.println("i = 0\n");
            JL_InfoProductoFoto.setIcon(fo0);
            i = 1;
        } else if (i == 1 && fo1 != null) { //2 imagenes
            System.out.println("i = 1\n");
            JL_InfoProductoFoto.setIcon(fo1);
            i = 2;
        } else if (i == 2 && fo2 != null) {//3 imagenes
            System.out.println("i = 2\n");
            JL_InfoProductoFoto.setIcon(fo2);
            i = 0;
        } else if (i == -1) { //0 imagenes
            System.out.println("i = -1\n");
            JOptionPane.showMessageDialog(this, "El Producto NO contiene imagenes");
        }

    }//GEN-LAST:event_JB_FotoSiguienteActionPerformed

    private void iniciarComboBoxCategoria() {

        ControladorCategoria jpaCateg = new ControladorCategoria();

        try {

            List<Categoria> ListaCategoria;
            ListaCategoria = jpaCateg.findCategoriaEntities();
            for (int i = 0; i < ListaCategoria.size(); i++) {

                Boolean tiene = ListaCategoria.get(i).getTieneProductos();
                //Si tiene productos me interesa mostrarlo
                if (tiene) {
                    String nickname = ListaCategoria.get(i).getNombre();
                    JCB_SelecCategorias.addItem(nickname);

                }

            }
        } catch (Exception e) {
            getToolkit().beep();
            JOptionPane.showMessageDialog(this, e.getMessage());
        }
    }

    //CARGA el ComboBox de PRODUCTO
    private void iniciarComboBoxProducto() {
        ControladorProducto jpaProd = new ControladorProducto();
        ControladorCategoria jpaCateg = new ControladorCategoria();
        String nomCat = JCB_SelecCategorias.getSelectedItem().toString();
        //JCB_ModProdSeleccioneProducto.setSelectedIndex(-1);
        if (JCB_SelecProducto.getItemCount() == 0) {
            try {
                List<Producto> ListaProducto;
                ListaProducto = jpaCateg.findCategoria(nomCat).getListadoProducto();
                for (int i = 0; i < ListaProducto.size(); i++) {
                    String nomProd = ListaProducto.get(i).getNombre();
                    JCB_SelecProducto.addItem(nomProd); //Inserta al comienzo
                }

            } catch (Exception e) {
                getToolkit().beep();
                JOptionPane.showMessageDialog(this, e.getMessage());
            }

        }//FIN IF
        else {

            try {
                JCB_SelecProducto.removeAllItems();
                List<Producto> ListaProducto;
                ListaProducto = jpaCateg.findCategoria(nomCat).getListadoProducto();
                for (int i = 0; i < ListaProducto.size(); i++) {
                    String nomProd = ListaProducto.get(i).getNombre();
                    JCB_SelecProducto.addItem(nomProd);
                }
            } catch (Exception e) {
                getToolkit().beep();
                JOptionPane.showMessageDialog(this, "Seleccione una categoria con productos\n");
            }
        }//FIN ELSE          
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JB_FotoSiguiente;
    private javax.swing.JButton JB_InfoProductoCerrar;
    private javax.swing.JComboBox JCB_SelecCategorias;
    private javax.swing.JComboBox JCB_SelecProducto;
    private javax.swing.JLabel JL_InfoProductoCategorias;
    private javax.swing.JLabel JL_InfoProductoDescripcion;
    private javax.swing.JLabel JL_InfoProductoEspecifiacion;
    private javax.swing.JLabel JL_InfoProductoFoto;
    private javax.swing.JLabel JL_InfoProductoNumReferencia;
    private javax.swing.JLabel JL_InfoProductoPesosUruguayos;
    private javax.swing.JLabel JL_InfoProductoPrecio;
    private javax.swing.JLabel JL_InfoProductoProveedor;
    private javax.swing.JLabel JL_InfoProductoTitulo;
    private javax.swing.JLabel JL_infoProductoInforProducto;
    private javax.swing.JLabel JL_infoProductoSeleccioneCategoria;
    private javax.swing.JLabel JL_infoProductoSeleccioneProducto;
    private javax.swing.JTextField JTF_InfoProductoCategorias;
    private javax.swing.JTextField JTF_InfoProductoDescripcion;
    private javax.swing.JTextField JTF_InfoProductoNumReferencia;
    private javax.swing.JTextField JTF_InfoProductoPrecio;
    private javax.swing.JTextField JTF_InfoProductoProveedor;
    private javax.swing.JTextField JTF_InfoProductoTitulo;
    private javax.swing.JTable JT_Productocategoria;
    private java.awt.TextArea TA_InfoProdEspecificaciones;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
